<template>
  <div class="tip" v-if="isShow">
    <div class="tip-header">App 改名字更新了</div>
    <div class="tip-body">{{ content }}</div>
    <div class="tip-footer">
      <button type="button" @click="clickCallback()" :disabled="disabled">去看看
      </button>
    </div>
  </div>
</template>
<script scoped>
  import ua from '../../assets/utils/userAgent'
  export default {
    name: 'Tip',
    props: ['is-show'],
    data () {
      return {
        content: '抱歉, 我们的 App 暂未支持您的设备',
        disabled: false
      }
    },
    methods: {
      clickCallback () {
        const osType = ua.getOS()
        if (osType === 'android') {
          // window.location = 'https://www.pgyer.com/XPQt'
          this.$router.go({ name: 'Download' })
        } else if (osType === 'ios') {
          window.location =
              'https://itunes.apple.com/us/app/zhang-hao-ban-lu/id992488773?l=zh&ls=1&mt=8'
        }
      }
    },
    ready () {
      const osType = ua.getOS()
      if (osType === 'ios') {
        this.content = '苹果用户请去 App Store 搜索: 《小树林》下载最新 App'
        // this.disabled = true
      } else if (osType === 'android') {
        this.content = '安卓用户请点击按钮立即下载'
      }
    }
  }
</script>
